<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/25
 * Time: 14:50
 */

namespace App\Http\Controllers\MiniProgram;

use App\Http\Logics\MiniProgram\DynamicLogic;
use App\Http\Traits\DynamicTrait;
use App\Http\Controllers\BaseController;
class DynamicController extends BaseController
{
    use DynamicTrait;

    /**
     * @SWG\Post(
     *     path="/dynamic/createPhoto",
     *     tags={"Dynamic"},
     *     description="发表图片动态",
     *     operationId="createPhotoDynamic",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *      @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="photo_list_str",
     *         in="query",
     *         description="图片列表字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="content",
     *         in="query",
     *         description="动态内容",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="latlng",
     *         in="query",
     *         description="经纬度坐标",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address",
     *         in="query",
     *         description="动态发布地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address_name",
     *         in="query",
     *         description="动态发布地址名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createPhotoDynamic()
    {
        $loginSession = $this->loginSession;
        $photo_list_str = $this->photo_list_str;
        $content = $this->content;
        $address = $this->address;
        $address_name = $this->address_name;
        $latlng = $this->latlng;
        $data = [
            'loginSession' => $loginSession,
            'photo_list_str' => $photo_list_str,
            'content' => $content,
            'address' => $address,
            'address_name' => $address_name,
            'latlng' => $latlng
        ];
        $response = DynamicLogic::createPhotoDynamic($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/dynamic/createVideo",
     *     tags={"Dynamic"},
     *     description="发表视频动态",
     *     operationId="createVideoDynamic",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *      @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="video_url",
     *         in="query",
     *         description="视频地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="video_height",
     *         in="query",
     *         description="视频高度",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="video_width",
     *         in="query",
     *         description="视频宽度",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="content",
     *         in="query",
     *         description="动态内容",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="latlng",
     *         in="query",
     *         description="经纬度坐标",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address",
     *         in="query",
     *         description="动态发布地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address_name",
     *         in="query",
     *         description="动态发布地址名称",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createVideoDynamic()
    {
        $loginSession = $this->loginSession;
        $video_url = $this->video_url;
        $content = $this->content;
        $address = $this->address;
        $address_name = $this->address_name;
        $latlng = $this->latlng;
        $data = [
            'loginSession' => $loginSession,
            'video_url' => $video_url,
            'content' => $content,
            'address' => $address,
            'address_name' => $address_name,
            'latlng' => $latlng
        ];
        $response = DynamicLogic::createVideoDynamic($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/dynamic/list",
     *     tags={"Dynamic"},
     *     description="获取动态列表",
     *     operationId="getDynamicList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *      @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="status",
     *         in="query",
     *         description="视频显示状态",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页大小",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getDynamicList()
    {
        $loginSession = $this->loginSession;
        $limit = $this->limit;
        $status = $this->status;
        $data = [
            'loginSession' => $loginSession,
            'status' => $status,
            'limit' => $limit,
            'is_transcode' => 1
        ];
        $response = DynamicLogic::getDynamicList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/dynamic/detail",
     *     tags={"Dynamic"},
     *     description="获取动态详情",
     *     operationId="getDynamicDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *      @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="dynamic_id",
     *         in="query",
     *         description="动态ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getDynamicDetail()
    {
        $dynamic_id = $this->dynamic_id;
        $loginSession = $this->loginSession;
        $data = [
            'dynamic_id' => $dynamic_id,
            'loginSession' => $loginSession
        ];
        $response = DynamicLogic::getDynamicDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}